<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义指令</title>
    <script src="js/vue.js"></script>
</head>
<body>
<div id="app">

</div>
<template id="tmp">
    <div>
        <p v-red>zzhangsan</p>
        <p>lisi</p>
        <p>wangwu</p>
    </div>
</template>
<script>
    Vue.directive("red", function (el) {
        el.style.backgroundColor = "red";
    });
    let app = new Vue({
        el: '#app',
        template: "#tmp"
    });

</script>
</body>
</html>